package com.manage.modules.controller;

import java.util.List;
import java.util.Arrays;

import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.manage.common.annotation.Log;
import com.manage.common.core.controller.BaseController;
import com.manage.common.core.domain.AjaxResult;
import com.manage.common.enums.BusinessType;
import com.manage.modules.vo.TBaseStationStateYunVo;
import com.manage.modules.bo.TBaseStationStateYunQueryBo;
import com.manage.modules.bo.TBaseStationStateYunAddBo;
import com.manage.modules.bo.TBaseStationStateYunEditBo;
import com.manage.modules.service.ITBaseStationStateYunService;
import com.manage.common.utils.poi.ExcelUtil;
import com.manage.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 站点状态列表Controller
 *
 * @author wx
 * @date 2021-09-07
 */
@Api(value = "站点状态列表控制器", tags = {"站点状态列表管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/modules/stationStateList")
public class TBaseStationStateYunController extends BaseController {

    private final ITBaseStationStateYunService iTBaseStationStateYunService;

    /**
     * 查询站点状态最新一条
     *
     * @return
     */
    @GetMapping("/listMap")
    public AjaxResult listMap() {
        return AjaxResult.success(iTBaseStationStateYunService.listMap());
    }

    /**
     * 查询站点状态列表列表
     */
    @ApiOperation("查询站点状态列表列表")
    @PreAuthorize("@ss.hasPermi('modules:stationStateList:list')")
    @GetMapping("/list")
    public TableDataInfo<TBaseStationStateYunVo> list(TBaseStationStateYunQueryBo bo) {
        startPage();
        List<TBaseStationStateYunVo> list = iTBaseStationStateYunService.queryList(bo);
        return getDataTable(list);
    }

    /**
     * 导出站点状态列表列表
     */
    @ApiOperation("导出站点状态列表列表")
    @PreAuthorize("@ss.hasPermi('modules:stationStateList:export')")
    @Log(title = "站点状态列表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<TBaseStationStateYunVo> export(TBaseStationStateYunQueryBo bo) {
        List<TBaseStationStateYunVo> list = iTBaseStationStateYunService.queryList(bo);
        ExcelUtil<TBaseStationStateYunVo> util = new ExcelUtil<TBaseStationStateYunVo>(TBaseStationStateYunVo.class);
        return util.exportExcel(list, "站点状态列表");
    }

    /**
     * 获取站点状态列表详细信息
     */
    @ApiOperation("获取站点状态列表详细信息")
    @PreAuthorize("@ss.hasPermi('modules:stationStateList:query')")
    @GetMapping("/{id}")
    public AjaxResult<TBaseStationStateYunVo> getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(iTBaseStationStateYunService.queryById(id));
    }

    /**
     * 新增站点状态列表
     */
    @ApiOperation("新增站点状态列表")
    @PreAuthorize("@ss.hasPermi('modules:stationStateList:add')")
    @Log(title = "站点状态列表", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody TBaseStationStateYunAddBo bo) {
        return toAjax(iTBaseStationStateYunService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改站点状态列表
     */
    @ApiOperation("修改站点状态列表")
    @PreAuthorize("@ss.hasPermi('modules:stationStateList:edit')")
    @Log(title = "站点状态列表", businessType = BusinessType.UPDATE)
    @PutMapping()
    public AjaxResult<Void> edit(@RequestBody TBaseStationStateYunEditBo bo) {
        return toAjax(iTBaseStationStateYunService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除站点状态列表
     */
    @ApiOperation("删除站点状态列表")
    @PreAuthorize("@ss.hasPermi('modules:stationStateList:remove')")
    @Log(title = "站点状态列表", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult<Void> remove(@PathVariable Long[] ids) {
        return toAjax(iTBaseStationStateYunService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
    }
}
